//
//  TripsTableViewCel.m
//  HappinessTrip
//
//  Created by dllo on 15/10/14.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "TripsTableViewCel.h"
#import "UIImageView+WebCache.h"
#import "Fit.h"

@implementation TripsTableViewCel
-(void)dealloc
{
    [_nameLabel release];
    [_likeLabel release];
    [super dealloc];
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createViews];
    }
    return self;
}
-(void)createViews
{
    self.pictureImageView = [[UIImageView alloc]init];
    [self.contentView addSubview:self.pictureImageView];
    [self.pictureImageView release];
    self.blackImageView = [[UIImageView alloc]init];
    [self.pictureImageView addSubview:self.blackImageView];
    [self.blackImageView release];
    
    _nameLabel = [[UILabel alloc]init];
    [self.pictureImageView addSubview:_nameLabel];
    [_nameLabel release];
    _likeLabel = [[UILabel alloc]init];
    [self.pictureImageView addSubview:_likeLabel];
    [_likeLabel release];
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    self.pictureImageView.frame = self.pictureImageView.frame;
    self.blackImageView.frame = self.blackImageView.frame;
    _nameLabel.frame = CGRectMake(20 * W, 10 * H, 295 * W, 40 * H);
    _likeLabel.frame = CGRectMake(_nameLabel.frame.origin.x, _nameLabel.frame.origin.y + _nameLabel.frame.size.height + 60 * H, _nameLabel.frame.size.width, 20 * H);
}
-(void)setTrip:(Trips *)trip
{
    if (_trip != trip) {
        [_trip release];
        _trip = [trip retain];
    }
    [self.pictureImageView sd_setImageWithURL:[NSURL URLWithString:_trip.cover_image_1600] placeholderImage:[UIImage imageNamed:@"dengdai"]];
    _nameLabel.text = _trip.name;
    _nameLabel.textColor = [UIColor whiteColor];
    _nameLabel.font = [UIFont systemFontOfSize:25];
    _likeLabel.text = [NSString stringWithFormat:@"%@次浏览 / %@喜欢 / %@评论", _trip.view_count, _trip.liked_count, _trip.total_comments_count];
    _likeLabel.textColor = [UIColor whiteColor];
    _likeLabel.font = [UIFont systemFontOfSize:15];
    
}



















/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
